<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\Referee;

class ResetRefereeRank extends Command
{
    protected $signature = 'dfjk:reset-agent-rank';
    protected $description = '重置推荐官积分排行榜';

    public function handle(Referee $referee)
    {
        $handler = app('App\Services\RankService')->setKey('referee-rank');
        $handler->zremrangebyrank(0, -1);
        $rows = $referee->all();
        foreach ($rows as $row) {
            $handler->zadd($row->point_total, $row->user_id);
        }
        $this->info("重置成功！");
    }
}
